package com.module.app.bean;

import android.text.TextUtils;

import androidx.annotation.Keep;

import com.module.app.base.BaseApplication;
import com.module.app.base.BaseApplication;
import com.module.base.cache.CacheSDK;
import com.module.base.utils.AppUtils;
import com.module.third.bean.lc.MyLCObject;

import java.io.Serializable;

import cn.leancloud.annotation.LCClassName;

/**
 * @author bsnl_yanxuwen
 * @date 2021/5/8 16:01
 * Description :
 * 配置信息
 */
@Keep
@LCClassName("Config")
public class ConfigBean implements Serializable, MyLCObject {

    public static ConfigBean getInstance() {
        ConfigBean configBean = CacheSDK.get(IType.ICache.CONFIG, ConfigBean.class);
        if (configBean == null) {
            configBean = new ConfigBean();
        }
        return configBean;
    }

    private String objectId;
    private String downloadApk = "";//apk地址
    private String downloadVivoApk = "";//vivo apk地址
    private String appVersionName = "0.0.1";//版本名称
    private int appVersionCode = 1;//版本号
    private String appVersionContent = "";//版本更新内容
    private boolean isForceUpdate;//是否强制更新
    private String notice = "";//通知内容
    private String slogan = "";//宣传口号
    private String poster = "";//宣传海报
    private String qrCode = "";//分享的二维码
    private String welcomeSlogan = "永久免费加密";//启动的宣传口号
    private String password;//万能密码
    private String qqGroupKey;//qq群Key ,通过https://qun.qq.com/join.html生成
    private AdConfig ad;
    private AdGroMoreConfig adGroMore;
    private SwitchConfig switchConfig;

    public String getDownloadApk() {
        //vivo更新单独处理
        if (AppUtils.getChannel().equals("vivo") && !TextUtils.isEmpty(downloadVivoApk)) {
            return downloadVivoApk;
        }
        return downloadApk;
    }

    public String getAppVersionName() {
        return appVersionName;
    }

    public int getAppVersionCode() {
        return appVersionCode;
    }

    public String getAppVersionContent() {
        return appVersionContent;
    }

    public boolean isForceUpdate() {
        return isForceUpdate;
    }

    public String getNotice() {
        return notice;
    }

    public String getSlogan() {
        return slogan;
    }

    public String getPoster() {
        return poster;
    }

    public String getQrCode() {
        return qrCode;
    }

    /**
     * 是否有版本更新
     */
    public boolean isUpdate() {
        if (appVersionCode > AppUtils.getVersionCode(BaseApplication.getContext())) {
            return true;
        }
        return false;
    }

    public String getWelcomeSlogan() {
        return welcomeSlogan;
    }

    public void setWelcomeSlogan(String welcomeSlogan) {
        this.welcomeSlogan = welcomeSlogan;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String getObjectId() {
        return objectId;
    }

    @Override
    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }

    @Override
    public String getClassName() {
        return null;
    }

    public String getQqGroupKey() {
        return qqGroupKey;
    }

    public void setQqGroupKey(String qqGroupKey) {
        this.qqGroupKey = qqGroupKey;
    }

    public AdConfig getAd() {
        //空的话，赋值一个新的，省的每个地方都要判空
        if (ad == null) {
            ad = new AdConfig();
        }
        return ad;
    }

    public void setAd(AdConfig ad) {
        this.ad = ad;
    }

    public SwitchConfig getSwitchConfig() {
        //空的话，赋值一个新的，省的每个地方都要判空
        if (switchConfig == null) {
            switchConfig = new SwitchConfig();
        }
        return switchConfig;
    }

    public void setSwitchConfig(SwitchConfig switchConfig) {
        this.switchConfig = switchConfig;
    }

    public AdGroMoreConfig getAdGroMore() {
        //空的话，赋值一个新的，省的每个地方都要判空
        if (adGroMore == null) {
            adGroMore = new AdGroMoreConfig();
        }
        return adGroMore;
    }

    public void setAdGroMore(AdGroMoreConfig adGroMore) {
        this.adGroMore = adGroMore;
    }
}
